package leecode

func decodeMessage(key string, message string) string {
	keyArr := []byte(key)
	hashMap := make(map[byte]byte)
	index := 0
	for _, key := range keyArr {
		if key == ' ' {
			continue
		}
		if _, ok := hashMap[key]; !ok {
			hashMap[key] = byte('a' + index)

			index++
		}
	}
	var result string
	for i := 0; i < len(message); i++ {
		if message[i] == ' ' {
			result += " "
		} else {
			result += string(hashMap[message[i]])
		}

	}
	return result
}
